package com.lyl.servicelive.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lyl.commonutils.R;
import com.lyl.servicelive.entity.Course;
import com.lyl.servicelive.entity.Visitor;
import com.lyl.servicelive.entity.vo.LiveCourseFormVo;
import com.lyl.servicelive.service.CourseAccountService;
import com.lyl.servicelive.service.CourseService;
import com.lyl.servicelive.service.VisitorService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 直播来访者记录表 前端控制器
 * </p>
 *
 * @author 雷艳玲
 * @since 2022-07-05
 */
@RestController
@RequestMapping("/servicelive/visitor")
public class VisitorController {



    @Autowired
    private VisitorService visitorService;
    @ApiOperation(value = "获取观看列表")
    @GetMapping("{courseId}/{page}/{size}")
    public R getInfo(@PathVariable("courseId") Long courseId,
                     @PathVariable("page") Long page,
                     @PathVariable("size") Long size) {


        Page<Visitor> pageParam = new Page<>(page, size);

        visitorService.pageQuery(pageParam, courseId);
        List<Visitor> records = pageParam.getRecords();

        long total = pageParam.getTotal();

        return  R.ok().data("total", total).data("rows", records);


    }

}

